/*
 *  Copyright 2001-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ar.uba.fi.posgrado.academy.web.form.course;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;

import ar.uba.fi.posgrado.academy.model.Course;
import ar.uba.fi.posgrado.academy.model.Instalment;

/**
 * Form para {@link Instalment cuotas}
 * 
 * @author ariel.piechotka
 */
@SuppressWarnings("serial")
public class InstalmentForm extends ActionForm {

	private Double registrationFeeValue;

	private Short qtyInstalments;

	private Short qtyRegFees;

	private Double instalmentValue;

	private List<String> instalmentsNames = new ArrayList<String>();
	private String[] instalmentsValues;
	
	private Course course;
	private Long courseId;

    private String debtTypeSelectedRegFee;
    private String debtTypeSelectedInst;
    private List<LabelValueBean> debtTypeOptions = new ArrayList<LabelValueBean>();

    @Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors actionErrors = new ActionErrors();

		return actionErrors;
	}

	public Double getInstalmentValue() {
		return instalmentValue;
	}

	public void setInstalmentValue(Double instalmentValue) {
		this.instalmentValue = instalmentValue;
	}

	public Short getQtyInstalments() {
		return qtyInstalments;
	}

	public void setQtyInstalments(Short qtyInstalments) {
		this.qtyInstalments = qtyInstalments;
		setInstalmentsNames();
	}

	public Double getRegistrationFeeValue() {
		return registrationFeeValue;
	}

	public void setRegistrationFeeValue(Double registrationFeeValue) {
		this.registrationFeeValue = registrationFeeValue;
	}

	public List<String> getInstalmentsNames() {
		return instalmentsNames;
	}

	public void setInstalmentsNames() {
		instalmentsNames.clear();
		for (int i = 1; i <= qtyInstalments; i++)
			instalmentsNames.add("Cuota " + i);
	}

	public List<LabelValueBean> getQtyInstalmentsOptions() {
		List<LabelValueBean> result = new ArrayList<LabelValueBean>();
		for (Integer i = 0; i <= Instalment.MAX_QTY_INSTALMENTS; i++)
			result.add(new LabelValueBean(i.toString(), i.toString()));
		return result;
	}
	
	public List<LabelValueBean> getQtyRegFeesOptions() {
		List<LabelValueBean> result = new ArrayList<LabelValueBean>();
		for (Integer i = 0; i <= Instalment.MAX_QTY_REG_FEES; i++)
			result.add(new LabelValueBean(i.toString(), i.toString()));
		return result;
	}

	public Course getCourse() {
		return course;
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public List<LabelValueBean> getDebtTypeOptions() {
		return debtTypeOptions;
	}

	public void setDebtTypeOptions(List<LabelValueBean> debtTypeOptions) {
		this.debtTypeOptions = debtTypeOptions;
	}

	public String getDebtTypeSelectedInst() {
		return debtTypeSelectedInst;
	}

	public void setDebtTypeSelectedInst(String debtTypeSelectedInst) {
		this.debtTypeSelectedInst = debtTypeSelectedInst;
	}

	public String getDebtTypeSelectedRegFee() {
		return debtTypeSelectedRegFee;
	}

	public void setDebtTypeSelectedRegFee(String debtTypeSelectedRegId) {
		this.debtTypeSelectedRegFee = debtTypeSelectedRegId;
	}

	public Long getCourseId() {
		return courseId;
	}

	public void setCourseId(Long courseId) {
		this.courseId = courseId;
	}

	public String[] getInstalmentsValues() {
		return instalmentsValues;
	}

	public void setInstalmentsValues(String[] instalmentsValues) {
		this.instalmentsValues = instalmentsValues;
	}

	public Short getQtyRegFees() {
		return qtyRegFees;
	}

	public void setQtyRegFees(Short qtyRegFees) {
		this.qtyRegFees = qtyRegFees;
	}
}
